package com.youxin.busfoundation.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

import com.youxin.foundation.mq.kafka.KafkaConfigBean;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * Kafka配置加载类
 * @author yingde.cao
 *
 */
@Configuration
@PropertySource("classpath:${spring.profiles.active}/kafka.properties")
@ConfigurationProperties(prefix="kafka")
public class KafkaConfig extends KafkaConfigBean{
	private static KafkaConfig config;
	private static Object lockObj=new Object();
	/**
	 * 程序启动时加载Kafka的配置
	 * @param kafkaConfig
	 */
	public static void initConfig(KafkaConfig kafkaConfig)
	{
		synchronized (lockObj) {
			if(config==null)
			{
				config=kafkaConfig;
			}
		}
	}
	
	/**
	 * 取Kafka配置
	 * @return
	 */
	public static KafkaConfig getConfig()
	{
		return config;
	}

}
